package com.general.client.widgets.iterablelist;

import com.general.client.action.ActionHandler;
import com.general.client.callback.Callback;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.HasWidgets;

public interface IIterableList extends HasWidgets {
	/** 
	 * callback with the index of new selection.
	 * -1 if new selection is null\not in list
	 * @param callback
	 */
	void onSelectionChanged(Callback<Integer> callback);
	
	/**
	 * callback with the index of new highlighted elem.
	 * -1 if new highlighted elem is null\not in list
	 */
	void onHighlightedChanged(Callback<Integer> callback);
	
	/** 
	 * @return index of selected elem., -1 if non selected 
	 */
	int getSelectedIndex();
	
	/**
	 * @return index of highlighted elem., -1 if non highlighted
	 */
	int getHighlightedIndex();
	
	/**
	 * @param index of new selection., -1 to select none
	 * values outside the list will be ignored (except -1 ...)
	 */
	void setSelectedIndex(int index);
	
	/**
	 * @param index of new highlighted elem., -1 to highlight none
	 * values outside the list will be ignored (except -1 ...)
	 */
	void setHighlightedIndex(int index);
	
	/**
	 * @param action for items (click\enter key)
	 */
	HandlerRegistration addActionHandler(ActionHandler action);
	
	/**
	 * @param blurHandler action for THE LIST losing focus
	 */
	HandlerRegistration addBlurHandler(BlurHandler blurHandler);
	
	/**
	 * @param styleName name for items when highlighted
	 */
	void addHighlightStyleName(String styleName);
	
	/**
	 * @param styleName name for items when selected
	 */
	void addSelectionStyleName(String styleName);
	
	/**
	 * @param styleName name for items when idle
	 */
	void addIdleStyleName(String styleName);
}
